package gbench.appdemo.mall.modules.stream.flume;

import org.junit.jupiter.api.Test;
import static gbench.common.tree.LittleTree.IRecord.*;
import static gbench.common.tree.LittleTree.*;

/**
 * 
 * @author gbench
 *
 */
public class FlumeConfig {
    
    @Test
    public void foo() {
        final var agentName = "agent1";
        final var sourceName = "source1";
        final var sinkName = "source1";
        final var channels  = "channels1";
        final var fileHeader = false;
        
        final var sourcetype = "hdfs";
        final var sinktype = "hdfs";
        final var spooldir = "hdfs";
        final var hdfs_path = "hdfs://master:8020/abouyunlog";
        final var hdfs_filetype = "DataStream";
        final var rec = REC(
                agentName,REC(
                        "channels",channels,
                        "sources",REC(
                                ".",sourceName,
                                agentName,REC(
                                        "type",sourcetype,
                                        "spoolDir",spooldir,
                                        "channels",channels,
                                        "fileHeader ",fileHeader
                                )
                        ),
                        "sinks",REC(
                                sinkName,REC(
                                        "type",sinktype,
                                        "hdfs",REC(
                                                "path",hdfs_path,
                                                "fileType",hdfs_filetype
                                        )// hdfs
                                )
                        )
                )
        );
        
        System.out.println();
        rec.dfs_eval_forone((String p, Object s)->{
            return MFT("{0}={1}",p.substring(1).replace("/", ".").replaceAll("\\.{2,}", ""),s);
        }).forEach(System.out::println);
    }
    
}
